package 最佳买卖股票时机含冷冻期;

public class Solution1 {
    public int maxProfit(int[] prices) {
        if(prices.length==0){
            return 0;
        }
        int len = prices.length;
        int[][] state = new int[len][3];

        state[0][0] = -prices[0];
        for(int i = 1; i < len ; i++){

            state[i][0] = Math.max(state[i-1][0],state[i-1][2]-prices[i]);
            state[i][1] = state[i-1][0] + prices[i];
            state[i][2] = Math.max(state[i-1][1],state[i-1][2]);
        }
        return Math.max(state[len-1][1],state[len-1][2]);
    }
}
